package view;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JToolBar;
import javax.swing.SpringLayout;
import javax.swing.JPanel;
import javax.swing.UIManager;

import dbhandelling.Connections;
import dbhandelling.MyAdapter;

import dbhandelling.Utility;

import java.awt.Color;
import java.awt.EventQueue;
import java.awt.SystemColor;



import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JTextField;

public class MainView extends JFrame implements ActionListener {

	
	private static final long serialVersionUID = 1L;
	private JPanel contentPane;
    private JPanel panel;
    private JTextField uid;
    private JTextField pwd;
    private JButton btnSubmit;
    
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		Connections.loadDriver();
		Connections.connect();
		
		
		
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					UIManager.setLookAndFeel(
					        UIManager.getSystemLookAndFeelClassName());
					MainView frame = new MainView();
				   frame.addWindowListener(new MyAdapter());
				   Utility.mv=frame;
					 
					
					
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
		
		
	}

	
	public MainView() {
		
		setBackground(Color.WHITE);
		setTitle("7 CHORDS");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		contentPane = new JPanel();
		contentPane.setBackground(SystemColor.window);
		
		setContentPane(contentPane);
		contentPane.setLayout(new BorderLayout(0, 0));
		
		JPanel panel_1 = new JPanel();
		contentPane.add(panel_1, BorderLayout.CENTER);
		SpringLayout sl_panel_1 = new SpringLayout();
		panel_1.setLayout(sl_panel_1);
		
		JLabel lblLogin = new JLabel("USER ID :");
		lblLogin.setFont(new Font("Tahoma", Font.BOLD, 25));
		sl_panel_1.putConstraint(SpringLayout.NORTH, lblLogin, 142, SpringLayout.NORTH, panel_1);
		sl_panel_1.putConstraint(SpringLayout.WEST, lblLogin, 179, SpringLayout.WEST, panel_1);
		panel_1.add(lblLogin);
		
		uid = new JTextField();
		sl_panel_1.putConstraint(SpringLayout.NORTH, uid, 0, SpringLayout.NORTH, lblLogin);
		sl_panel_1.putConstraint(SpringLayout.WEST, uid, 6, SpringLayout.EAST, lblLogin);
		sl_panel_1.putConstraint(SpringLayout.SOUTH, uid, 0, SpringLayout.SOUTH, lblLogin);
		sl_panel_1.putConstraint(SpringLayout.EAST, uid, 216, SpringLayout.EAST, lblLogin);
		panel_1.add(uid);
		uid.setColumns(10);
		
		JLabel lblPassWord = new JLabel("PASS WORD :");
		sl_panel_1.putConstraint(SpringLayout.NORTH, lblPassWord, 40, SpringLayout.SOUTH, lblLogin);
		sl_panel_1.putConstraint(SpringLayout.EAST, lblPassWord, 0, SpringLayout.EAST, lblLogin);
		lblPassWord.setFont(new Font("Tahoma", Font.BOLD, 25));
		panel_1.add(lblPassWord);
		
		pwd = new JTextField();
		sl_panel_1.putConstraint(SpringLayout.NORTH, pwd, 0, SpringLayout.NORTH, lblPassWord);
		sl_panel_1.putConstraint(SpringLayout.WEST, pwd, 6, SpringLayout.EAST, lblPassWord);
		sl_panel_1.putConstraint(SpringLayout.SOUTH, pwd, 0, SpringLayout.SOUTH, lblPassWord);
		sl_panel_1.putConstraint(SpringLayout.EAST, pwd, 0, SpringLayout.EAST, uid);
		pwd.setColumns(10);
		panel_1.add(pwd);
		
		btnSubmit = new JButton("SUBMIT");
		sl_panel_1.putConstraint(SpringLayout.NORTH, btnSubmit, 54, SpringLayout.SOUTH, pwd);
		sl_panel_1.putConstraint(SpringLayout.EAST, btnSubmit, -160, SpringLayout.EAST, panel_1);
		panel_1.add(btnSubmit);
		btnSubmit.addActionListener(this);
		
		
	}
	
	/*
	 * This method creates an array of distinct name
	 */
	
	
	
	
	
	public void set_panel(JPanel p)
	{
		
		contentPane.removeAll();
		contentPane.add(p);
	
		contentPane.validate();
		contentPane.repaint();
	}


	@Override
	public void actionPerformed(ActionEvent arg0) {
		
		
}
}
